package com.sx.wechat.command.api;

import com.sx.core.mybatis.SessionTemplate;
import com.sx.core.vo.JsonReaderResponse;
import com.sx.wechat.command.cmd.AbstractCommand;
import com.sx.wechat.security.AuthenticationHolder;
import com.sx.wechat.security.Principal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 挂失解挂
 * Created by lihao on 2018/3/21.
 */
@Component("get_student_order_score")
public class Get_student_order_score extends AbstractCommand {
    @Autowired
    SessionTemplate sessionTemplate;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    NamedParameterJdbcTemplate namedParameterJdbcTemplate;


    @Override
    public Object executeApi(HttpServletRequest request, HttpServletResponse response) {
        String orderid=obtain(request,"orderid");
        Principal principal= AuthenticationHolder.getCurrent();
        String sql="select * from t_all_score WHERE stuid=? AND orderid=?";
        String sql1="select * from t_part_score WHERE stuid=? AND orderid=?";
        return new JsonReaderResponse(jdbcTemplate.queryForList(sql1,principal.getId(),orderid)).addExtra(jdbcTemplate.queryForMap(sql,principal.getId(),orderid));
    }
}
